package com.chen.service.impl;

import com.chen.dao.UserDao;
import com.chen.entity.UserEntity;
import com.chen.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;

@Service
public class UserServiceImpl implements UserService {

    private UserDao userDao = new UserDao();

    public void strIsEmpty(String str, HttpServletRequest req, HttpServletResponse resp) {
        try {
            if (StringUtils.isEmpty(str)) {
                req.setAttribute("errorMsg", "错误原因：" + str + "为空值");
                req.getRequestDispatcher("error.jsp").forward(req, resp);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public ArrayList<UserEntity> getByAll() {
        return userDao.getByAll();
    }

    public int updateDeleteByPhone(String phone) {
        return userDao.updateDeleteByPhone(phone);
    }

    public UserEntity getByPhoneUser(String phone) {
        return userDao.getByPhoneUser(phone);
    }
}
